<?php
require_once( 'path.php' );

//调用初始化页面
require_once( CLASSMATE_ROOT.'/controller/display_script_init.php' );
require_once( CLASSMATE_ROOT.'/include/function/mongo_connect.function.php' );

if( !session::get('is_online') ){
	
	$response_message = array( 'type'=>'notice' ,
				 'content'=>'您还没有登录，不能进行此操作。' , 
				 'url_des'=>'马上去登录？' ,
				 'url'=>'/classmate/controller/account/login.php' );
				 
	session::set( 'response_message' , $response_message );
	header( 'Location: ../response_message.php' );
	exit();
}

//如果是由于更新用户信息发生异常重定向而来
if( session::get('update_fail_message' ) ){

	$tpl->assign( 'upload_fail_message' , session::get( 'upload_fail_message' ) );
	session::clear( 'upload_fail_message' );
}

//需从数据库中取出数据放入输入框中便于用户识别，并判断是否有修改的
//必要性
$db_connect = mongo_connect();

$db_obj_user_profile = new db_obj_user_profile( $db_connect );
$db_obj_user = new db_obj_user( $db_connect );

//分别实例化用户信息以及用户详细信息
$db_obj_user->load( 'email' , session::get( 'email' ) );
$db_obj_user_profile->load( 'email' , session::get( 'email' ) );

//赋值给模板
$tpl->assign( 'nick' , $db_obj_user->get( 'nick' ));
$tpl->assign( 'signature' , $db_obj_user_profile->get( 'signature' ) );
$tpl->assign( 'self_intro' , $db_obj_user_profile->get( 'self_intro' ) );

$tpl->assign( 'head_url' , $db_obj_user_profile->get( 'head_url' ) );

$tpl->assign( 'title' , '更新用户信息' );
$tpl->display( 'account/update_user_profile.tpl' );

